package com.pb.wkflow.api.controller.assembler.mapper;

import com.pb.wkflow.api.config.Constants;
import com.pb.wkflow.api.controller.request.TaskHandOverCreateRequest;
import com.pb.wkflow.api.entity.TaskHandOverEntity;
import com.pb.wkflow.core.utils.DateUtils;
import com.pb.wkflow.core.utils.SnowFlake;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.Date;

/**
 * @author 苗益辉
 * @date 2022/12/26 16:26
 */
@Mapper(imports = {Constants.class, SnowFlake.class, DateUtils.class, Date.class})
public interface TaskHandOverDtoMapper {

    TaskHandOverDtoMapper INSTANCE = Mappers.getMapper(TaskHandOverDtoMapper.class);

    /**
     * assemblerToCreate
     * @param request request
     * @return TaskHandOverEntity
     */
    @Mapping(target = "id", expression = "java(SnowFlake.nextId())")
    @Mapping(target = "delFlag", expression = "java(Constants.NOT_DEL_FLAG)")
    @Mapping(target = "createTime", expression = "java(DateUtils.dateToStr(new Date()))")
    @Mapping(target = "updateTime", expression = "java(DateUtils.dateToStr(new Date()))")
    TaskHandOverEntity assemblerToCreate(TaskHandOverCreateRequest request);

    /**
     * assemblerToEdit
     * @param request request
     * @return TaskHandOverEntity
     */
    @Mapping(target = "updateTime", expression = "java(DateUtils.dateToStr(new Date()))")
    TaskHandOverEntity assemblerToEdit(TaskHandOverCreateRequest request);

    /**
     * assemblerToDelete
     * @param request request
     * @return TaskHandOverEntity
     */
    @Mapping(target = "delFlag", expression = "java(Constants.DEL_FLAG)")
    @Mapping(target = "updateTime", expression = "java(DateUtils.dateToStr(new Date()))")
    TaskHandOverEntity assemblerToDelete(TaskHandOverCreateRequest request);
}